package com.njtoyo.netrides.entity;

import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.util.Date;
import java.util.Map;

/**
 * @Author: myx
 * @Date: 2020/12/7 9:49
 */
@Entity
@Table(name = "activity_team_member")
@Accessors(chain = true)
@Data
public class ActivityTeamMember {

    /**
     * 主键
     */
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;


    /**
     * 助力团队的id
     */
    @JsonIgnore
    private Long teamId;

    /**
     * 助力的乘客id
     */
    private Long customerId;

    /**
     * 是否是发起人
     */
    private Boolean isInitiator;

    /**
     * 是否是新用户
     */
    private Boolean isNewPassenger;

    /**
     * 加入团队时间戳
     */
    private Integer joinedTimestamp;

    /**
     * 奖励类型
     */
    @Enumerated
    private Znum.ActivityRewardCtg rewardCategory;

    /**
     * 奖励内容
     */
    private String rewardInfo;

    /**
     * 创建时间
     */
    @JsonIgnore
    private Date createdAt;

    /**
     * 修改时间
     */
    @JsonIgnore
    private Date updatedAt;


    public void setRewardInfo(Map rewardInfo) {
        this.rewardInfo = JSONUtil.toJsonStr(rewardInfo);
    }
}
